using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SkeleGroundState : SkeleEnemyState
{
    Transform player;

    public SkeleGroundState(SkeleEnemy skele, StateMachine stateMachine, string animName) : base(skele, stateMachine, animName)
    {
    }

    public override void Enter()
    {
        base.Enter();
        player = PlayerManager.Instance.Player.transform;
    }

    public override void Exit()
    {
        base.Exit();
    }

    public override void Update()
    {
        base.Update();

        if (!player.GetComponent<PlayerData>().isDead)
        {
            if (skele.IsPlayerDetected() || Vector3.Distance(player.transform.position, skele.transform.position) < 2f)
                stateMachine.ChangeState(skele.battleState);
        }
        
    }
}
